package br.edu.ufcg.lsd.wbis.ui.client.ui.loggedin.admin.user;

import br.edu.ufcg.lsd.wbis.ui.client.beans.UserInfo;
import br.edu.ufcg.lsd.wbis.ui.client.ui.loggedin.admin.GenericTabPanel;
import br.edu.ufcg.lsd.wbis.ui.client.ui.management.DefaultUserInfoManager;
import br.edu.ufcg.lsd.wbis.ui.client.ui.management.InfoManager;
import br.edu.ufcg.lsd.wbis.ui.client.ui.management.OtherUserInfoManager;

import com.gwtext.client.widgets.TabPanel;

/**
 * @author Renato Miceli
 */
public class UserTab extends GenericTabPanel {

	private final DefaultUserInfoManager manager;

	private final UserInfo info;

	public UserTab(UserInfo info, TabPanel centerPanel, InfoManager<UserInfo> loggedManager) {

		this.info = info;
		this.manager = new OtherUserInfoManager(info, loggedManager);
		this.manager.start();

		this.setTitle("User " + info.getLogin());
		this.add(new UserPortal(centerPanel, manager, loggedManager));
		this.addListener(this.manager);
		
		System.err.println("CREATED TAB WITH ID: " + getTabId());
	}

	/**
	 * {@inheritDoc}
	 */
	@Override
	public String getTabId() {
		return getTabId(info.getLogin());
	}

	public static String getTabId(String userLogin) {
		return "USER_" + userLogin;
	}

}